package learn.basics.interface1.demo1;

interface MyInterfaceAbstract {
    public abstract void MethodAbs1();

    abstract void MethodAbs2();

    public void MethodAbs3();

    void MethodAbs4();
}

class MyInterfaceAbstractImpl implements MyInterfaceAbstract {

    @Override
    public void MethodAbs1() {
        System.out.println("这是第一个");

    }

    @Override
    public void MethodAbs2() {
        System.out.println("这是第二个");

    }

    @Override
    public void MethodAbs3() {
        System.out.println("这是第三个");
    }

    @Override
    public void MethodAbs4() {
        System.out.println("这是第四个");
    }
}

class Demo1Interface {
    public static void Test() {
        MyInterfaceAbstractImpl impl = new MyInterfaceAbstractImpl();

        impl.MethodAbs1();
        impl.MethodAbs2();

    }
}


interface MyInterfaceDefault {
    public abstract void MethodAbs();

    public default void MethodDefault() {
        System.out.println("这是一个新加的默认方法");
    }
}


class MyInterfaceDefaultA implements MyInterfaceDefault {

    @Override
    public void MethodAbs() {
        System.out.println("实现了抽象方法");
    }
}


class MyInterfaceDefaultB implements MyInterfaceDefault {

    @Override
    public void MethodAbs() {
        System.out.println("实现了抽象方法 BBBB");
    }

    @Override
    public void MethodDefault() {
        System.out.println("覆盖了接口的默认方法 BBBB");

    }
}


class Demo2Interface {
    public static void Test() {
        MyInterfaceDefaultA a = new MyInterfaceDefaultA();
        a.MethodAbs();
        a.MethodDefault();

        System.out.println("====================");
        MyInterfaceDefaultB b = new MyInterfaceDefaultB();
        b.MethodAbs();
        b.MethodDefault();
    }
}

interface MyInterfaceStatic {
    public static void MethodStatic() {
        System.out.println("这是接口的静态方法");
    }
}

class MyInterfaceStaticImpl implements MyInterfaceStatic {

}

class Demo3Interface {
    public static void Test() {
        MyInterfaceStaticImpl impl = new MyInterfaceStaticImpl();
        // impl.MethodStatic(); //错误写法

        // 正确写法
        MyInterfaceStatic.MethodStatic();
    }
}

interface MyInterfaceConst {
    public static final int NUM_OF_CLASS = 12;
}

class Demo5Interface {
    public static void Test() {
        System.out.println(MyInterfaceConst.NUM_OF_CLASS);
    }
}






















public class TestInterface {
    public static void main(String[] args) {
        //Demo1Interface.Test();
        //Demo2Interface.Test();
        //Demo3Interface.Test();
        Demo5Interface.Test();
    }
}

